var detailClassName=[
	{name:'#infor-where-select'},{name:'.reSearchSource'},{name:'#Part'},{name:'.pes'},{name:'.sort'},
	{name:'.briefing'},{name:'#content'},{name:'.basic'},{name:'.step'},{name:'#fileUp'},{name:'.retu'},
	{name:'.delete'},{name:'#requestUpdate'},{name:'.info-sub-a'},{name:'#submitInfo'}
];
/*var serchClassName=[
	{name:'#profile'},{name:'.reSearchpes'},{name:'.reSearchsort'},{name:'.reSearchSource'},{name:'.reSearchFlow'},
	{name:'.rePort'},{name:'.repingjia'},{name:'#requestName'},{name:'#refinishName'},{name:'.reDepartment'},
	{name:'.reinputDian'},{name:'.refinishDian'},{name:'#submitstarTime'},{name:'#submitendTime'},{name:'#finishstarTime'}
	,{name:'#finishendTime'},{name:'#starTime'},{name:'#endTime'},{name:'#firstSearch'}
];*/
var personSelect=[{name:'#accountOrName'},{name:'#queryUser'},{name:'.department'},{name:'.child'},
{name:'.modal-footer .btn-default'},{name:'.modal-footer .btn-primary'}];
var saveModal=[{name:'.modal-footer .btn-default'},{name:'.modal-footer .btn-primary'}];
var thisClassName=[];
var tab_Index=-1;
var per_index=-1;
var save_index=-1;
$(function(){
	if($("#profile").length>0){
		$("#profile").focus();
	}
	$(document).keydown(function(event){
		if($("#myPart").hasClass('in')){
			thisClassName=personSelect;
		}else if($("#myModal").hasClass('in')){
			thisClassName=saveModal;
		}else{
			thisClassName=detailClassName;
		}
	  switch(event.keyCode) {
	    case 39: 
	    	toNextTabIndex(thisClassName);
	    	break;
	    case 37:
	    	toPrevTabIndex(thisClassName);
	    	break;
	  }
	});

})


function toNextTabIndex(newName){
	if(newName.length==personSelect.length){
		per_index++;
		$(newName[per_index].name).focus();
	}else if(newName.length==saveModal.length){
		save_index++;
		$(newName[save_index].name).focus();
	}else{
		tab_Index++;
		for(var i=0;i<newName.length;i++){
			var s=isFind(newName[tab_Index].name);
			if(s>0){
				break;
			}
			tab_Index++;
		}
		$(newName[tab_Index].name).focus();
	}	
	

}
function toPrevTabIndex(newName){
	if(newName.length==personSelect.length){
		per_index--;
		$(newName[per_index].name).focus();

	}else if(newName.length==saveModal.length){
		save_index--;
		$(newName[save_index].name).focus();
	}else{
		tab_Index--;
		for(var i=0;i<newName.length;i++){
			var s=isFind(newName[tab_Index].name);
			if(s>0){
				break;
			}
			tab_Index--;
		}
		$(newName[tab_Index].name).focus();	
	}
	
}
function isFind(className){
	if($(className).length>0){
		return 1;
	}else{
		return 0;
	}
}



